Try catch throw in JavaScript